package com.hnkywl.sts.entity.xsgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.cggl.Glfy;
import com.hnkywl.sts.entity.cggl.Jsd;
import com.hnkywl.sts.entity.htgl.Xsht;
import com.hnkywl.sts.entity.organ.*;
import com.hnkywl.sts.entity.sys.Yg;
import org.hibernate.annotations.*;

import javax.persistence.Entity;
import javax.persistence.*;
import javax.persistence.Table;
import java.util.Date;
import java.util.List;

/**
 * 说明：销售单
 * 包:        com.hnkywl.sts.entity.xsgl
 * 类描述:    销售单
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Entity
@Table(name = "T_BIZ_LLD")
@Where(clause = "deleted!='1'")
public class Lld extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqLld", allocationSize = 1, sequenceName = "SEQ_BIZ_LLD")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqLld")
    private Long id;

    /**
     * 领料单号
     */
    private String lldh;
    /**
     * 开单日期
     */
    private Date kdrq;

    /**
     * 发料公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FLGS_ID")
    private Nbgs flgs;

    /**
     * 发料部门
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FlBM_ID")
    private Gsjg flbm;

    /**
     * 发料人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "FLR_ID")
    private Yg flr;

    /**
     * 提货仓库
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CK_ID")
    private Ck thck;
    /**
     * 开单数量总和
     */
    @Formula("(select sum(t.KDSL) from T_BIZ_LLDMX t where t.LLD_ID=ID and DELETED!=1)")
    private Float kdslzh;
    /**
     * 开单金额总和
     */
    @Formula("(select sum(t.KDJE) from T_BIZ_LLDMX t where t.LLD_ID=ID and DELETED!=1)")
    private Float kdjezh;
    /**
     * 发料数量总和
     */
    @Formula("(select sum(t.FLSL) from T_BIZ_LLDMX t where t.LLD_ID=ID and DELETED!=1)")
    private Float flslzh;
    /**
     * 发料金额总和
     */
    @Formula("(select sum(t.FLJE) from T_BIZ_LLDMX t where t.LLD_ID=ID and DELETED!=1)")
    private Float fljezh;

    /**
     * 领料公司
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LLGS_ID")
    private Nbgs llgs;

    /**
     * 领料部门
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LLBM_ID")
    private Gsjg llbm;

    /**
     * 领料人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "LLR_ID")
    private Yg llr;

    /**
     * 审核人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SHR_ID")
    private Yg shr;

    /**
     * 发料日期
     */
    private Date flrq;
    /**
     * 开单人
     */
    private String kdr;
    /**
     * 状态
     */
    private String zt;
    /**
     * 备注
     */
    private String bz;

    /**
     * 领料单明细
     */
    @OneToMany(fetch = FetchType.LAZY, targetEntity = Lldmx.class)
    @Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
    @JoinColumn(name = "LLD_ID")
    @Where(clause = "deleted!='1'")
    private List<Lldmx> lldmxList;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLldh() {
        return lldh;
    }

    public void setLldh(String lldh) {
        this.lldh = lldh;
    }

    public Date getKdrq() {
        return kdrq;
    }

    public void setKdrq(Date kdrq) {
        this.kdrq = kdrq;
    }

    public Nbgs getFlgs() {
        return flgs;
    }

    public Yg getShr() {
        return shr;
    }

    public void setShr(Yg shr) {
        this.shr = shr;
    }

    public void setFlgs(Nbgs flgs) {
        this.flgs = flgs;
    }

    public Gsjg getFlbm() {
        return flbm;
    }

    public void setFlbm(Gsjg flbm) {
        this.flbm = flbm;
    }

    public Yg getFlr() {
        return flr;
    }

    public void setFlr(Yg flr) {
        this.flr = flr;
    }

    public Ck getThck() {
        return thck;
    }

    public void setThck(Ck thck) {
        this.thck = thck;
    }

    public Float getKdslzh() {
        return kdslzh;
    }

    public void setKdslzh(Float kdslzh) {
        this.kdslzh = kdslzh;
    }

    public Float getKdjezh() {
        return kdjezh;
    }

    public void setKdjezh(Float kdjezh) {
        this.kdjezh = kdjezh;
    }

    public Float getFlslzh() {
        return flslzh;
    }

    public void setFlslzh(Float flslzh) {
        this.flslzh = flslzh;
    }

    public Float getFljezh() {
        return fljezh;
    }

    public void setFljezh(Float fljezh) {
        this.fljezh = fljezh;
    }

    public Nbgs getLlgs() {
        return llgs;
    }

    public void setLlgs(Nbgs llgs) {
        this.llgs = llgs;
    }

    public Gsjg getLlbm() {
        return llbm;
    }

    public void setLlbm(Gsjg llbm) {
        this.llbm = llbm;
    }

    public Yg getLlr() {
        return llr;
    }

    public void setLlr(Yg llr) {
        this.llr = llr;
    }

    public Date getFlrq() {
        return flrq;
    }

    public void setFlrq(Date flrq) {
        this.flrq = flrq;
    }

    public String getKdr() {
        return kdr;
    }

    public void setKdr(String kdr) {
        this.kdr = kdr;
    }

    public String getZt() {
        return zt;
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public List<Lldmx> getLldmxList() {
        return lldmxList;
    }

    public void setLldmxList(List<Lldmx> lldmxList) {
        this.lldmxList = lldmxList;
    }
}
